

package crudfx.field;

import javax.swing.border.*;
import javafx.scene.paint.*;
import javax.swing.*;
//import java.awt.*;
import crudfx.interop.*;
/**
 * @profile desktop
 * @author Sergey Surikov
 */
public class ArtTextField extends TextField{
    public var upOn:ImageIcon;
    public var upOff:ImageIcon;
    public var downOn:ImageIcon;
    public var downOff:ImageIcon;
    public var leftOn:ImageIcon;
    public var leftOff:ImageIcon;
    public var rightOn:ImageIcon;
    public var rightOff:ImageIcon;
    public var verticalTrack:UIComponent;
    public var verticalThumb:UIComponent;
    public var horizontalTrack:UIComponent;
    public var horizontalThumb:UIComponent;
  public var color:Color=Color.web("#000000") on replace{
        jTextArea.setForeground(new java.awt.Color(color.red,color.green,color.blue,color.opacity));
        };
    public var selectionColor:Color=Color.web("#000000") on replace{
        jTextArea.setSelectedTextColor(new java.awt.Color(selectionColor.red
            ,selectionColor.green,selectionColor.blue,selectionColor.opacity));
        };
    public var selectionBackground:Color=Color.web("#000000") on replace{
        jTextArea.setSelectionColor(new java.awt.Color(selectionBackground.red
            ,selectionBackground.green,selectionBackground.blue,selectionBackground.opacity));
        };
    public-init var bold:Boolean=false;
    public-init var italic:Boolean=false;
    public-init var serifs:Boolean=false;
    public-init var monospaced:Boolean=false;
    public-init var size:Number=9;
    init{
        jTextArea.setBorder(new EmptyBorder(0,0,0,0));
        jTextArea.setOpaque(false);
        jTextArea.setBackground(new java.awt.Color(0,0,0,0));
        jTextArea.setForeground(new java.awt.Color(color.red,color.green,color.blue,color.opacity));
        jTextArea.setSelectedTextColor(new java.awt.Color(selectionColor.red
            ,selectionColor.green,selectionColor.blue,selectionColor.opacity));
        jTextArea.setSelectionColor(new java.awt.Color(selectionBackground.red
            ,selectionBackground.green,selectionBackground.blue,selectionBackground.opacity));
        var fn:String="SansSerif";
        if(monospaced)fn="Monospaced";
        if(serifs)fn="Serif";
        var fst:Integer=0;
        if(bold)fst=fst+java.awt.Font.BOLD;
        if(italic)fst=fst+java.awt.Font.ITALIC;
        var font:java.awt.Font=new java.awt.Font(fn,fst,size);
        jTextArea.setFont(font);
        jScrollPane.getViewport().setOpaque(false);
        jScrollPane.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
        jScrollPane.setViewportBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
        jScrollPane.setOpaque(false);
        jTextArea.setOpaque(false);

        var verticalThumbPanel:JPanel=new JPanel(false);
        var verticalTrackPanel:JPanel=new JPanel(false);
        var horizontalThumbPanel:JPanel=new JPanel(false);
        var horizontalTrackPanel:JPanel=new JPanel(false);
        verticalThumbPanel.setOpaque(false);
        verticalThumbPanel.setLayout(new java.awt.BorderLayout());
        if(verticalThumb==null)verticalThumb=StandardLabel{};
        verticalThumbPanel.add(verticalThumb.getJComponent(),java.awt.BorderLayout.CENTER);
        verticalTrackPanel.setOpaque(false);
        verticalTrackPanel.setLayout(new java.awt.BorderLayout());
        if(verticalTrack==null)verticalTrack=StandardLabel{};
        verticalTrackPanel.add(verticalTrack.getJComponent(),java.awt.BorderLayout.CENTER);
        horizontalThumbPanel.setOpaque(false);
        horizontalThumbPanel.setLayout(new java.awt.BorderLayout());
        if(horizontalThumb==null)horizontalThumb=StandardLabel{};
        horizontalThumbPanel.add(horizontalThumb.getJComponent(),java.awt.BorderLayout.CENTER);
        horizontalTrackPanel.setOpaque(false);
        horizontalTrackPanel.setLayout(new java.awt.BorderLayout());
        if(horizontalTrack==null)horizontalTrack=StandardLabel{};
        horizontalTrackPanel.add(horizontalTrack.getJComponent(),java.awt.BorderLayout.CENTER);
        if(upOn==null)upOn=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(upOff==null)upOff=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(downOn==null)downOn=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(downOff==null)downOff=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(leftOn==null)leftOn=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(leftOff==null)leftOff=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(rightOn==null)rightOn=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(rightOff==null)rightOff=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        crudfx.control.GridTools.installScrollBars(this.jScrollPane
            ,upOn,upOff,downOn,downOff,leftOn,leftOff,rightOn,rightOff
            ,verticalTrackPanel
            ,verticalThumbPanel
            ,horizontalTrackPanel
            ,horizontalThumbPanel
            );
        jScrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,new JLabel(""));
        }
}
